package com.cgbl.cg.vm.main

import android.app.Application
import androidx.databinding.ObservableInt
import com.robot.base.base.vm.GLBaseViewModel
import com.robot.base.configs.AppConstants
import com.robot.base.util.arouter.ARouterUtil
import me.goldze.mvvmhabit.binding.command.BindingAction
import me.goldze.mvvmhabit.binding.command.BindingCommand
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent

class HomeFragmentViewModel(application: Application) : GLBaseViewModel(application) {
    val tabType = ObservableInt(TAB_RECOMMEND)
    val uc = UiChangeEvent()

    class UiChangeEvent {
        val tabType: SingleLiveEvent<Int> = SingleLiveEvent()
    }

    val clickSelectRecommend = BindingCommand<Any>(BindingAction {
        tabType.set(TAB_RECOMMEND)
        uc.tabType.postValue(TAB_RECOMMEND)
    })

    val clickSelectFollow = BindingCommand<Any>(BindingAction {
        tabType.set(TAB_FOLLOW)
        uc.tabType.postValue(TAB_FOLLOW)
    })

    val clickSelectWork = BindingCommand<Any>(BindingAction {
        tabType.set(TAB_WORK)
        uc.tabType.postValue(TAB_WORK)
    })

    val clickSelectCourse = BindingCommand<Any>(BindingAction {
        tabType.set(TAB_COURSE)
        uc.tabType.postValue(TAB_COURSE)
    })

    val clickSelectResource = BindingCommand<Any>(BindingAction {
        tabType.set(TAB_RESOURCE)
        uc.tabType.postValue(TAB_RESOURCE)
    })

    val clickSelectProject = BindingCommand<Any>(BindingAction {
        tabType.set(TAB_PROJECT)
        uc.tabType.postValue(TAB_PROJECT)
    })

    val toSearchCommand = BindingCommand<Any>(BindingAction {
        ARouterUtil.goToActivity(AppConstants.Router.HOME.A_SEARCH)
    })


    companion object {
        const val TAB_RECOMMEND = 0

        const val TAB_FOLLOW = 1

        const val TAB_WORK = 2

        const val TAB_COURSE = 3

        const val TAB_RESOURCE = 4

        const val TAB_PROJECT = 5
    }
}